import { removeToken, getToken, setToken } from '@/utils/storage'
// /用户的store模块
// /每个模块都有自己的state/mutations/actions,/getters
// import { setToken, getToken } from '@/utils/storage'
// vuex 用户模块
const state = {
  // userToken: getToken()
  userToken: getToken() || {}

}
const mutations = {
  setUserToken (state, newToken) {
    state.userToken = newToken
    setToken(newToken)
  },
  // 移出tokenInfo的信息, 恢复成空对象
  removeToken (state) {
    state.userToken = {}
    // 更新到本地, 本地可以清掉token信息
    removeToken()
  }
}
const getters = {}
const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions
}
